﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using USERS.CYT369.COM.Models;

namespace USERS.CYT369.COM.Controllers
{
    public class RulesController : AllowAnonymousController
    {
        public ActionResult Index(int? id)
        {
            var terms = USERS.CYT369.COM.DAL.TermsService.Instance.GetTerms(id);

            return View(terms);
        }

        [HttpPost]
        public ActionResult Index()
        {
            string searchkey = Request.Form["searchkey"];

            var terms = USERS.CYT369.COM.DAL.TermsService.Instance.GetTerms(name: searchkey);

            return View(terms);
        }

        public ActionResult RuleView(string id)
        {
            var argsJson = Base64.Base64ToJSON(id);
            var terms = USERS.CYT369.COM.DAL.TermsService.Instance.GetTermsByID(argsJson.GetInteger("RuleID", 0));

            return View(terms);
        }

    }
}
